package com.tdx.blog_nowcoder.utils;

public class RedisKeyUtils {
    private static final String SPLIT = ":";
    private static final String PREFIX_ENTITY_LIKE="like:entity";

    private static final String PREFIX_USER_LIKE="like:user";

    private static final String PREFIX_FOllOWER="follower"; // 哪些粉丝

    private static final String PREFIX_FOllOWEE="followee"; // 关注的目标对象

    private static final String PREFIX_LOGIN_TICKET = "login_ticket";

    private static final String PREFIX_USER = "user";

    private static final String PREFIX_KAPTH = "kapth";

    private static  final String PREFIX_UV = "uv"; // unique vistor

    private static  final String PREFIX_DAU = "dau"; // Daily Active User

    private static  final String PREFIX_POST = "post_score"; // 贴子的分数




    //赞的是某个实体
    public static String getEntityLike(int entityType,int entityID){
        return PREFIX_ENTITY_LIKE+SPLIT+entityType+SPLIT+entityID;
    }


    // 某个用户的赞
    // like:user:userId -> int   like:user:101 :(102,103,105)
    public static String getUserLikeKey(int userId) {
        return PREFIX_USER_LIKE + SPLIT + userId;
    }



    // 某个用户关注的实体
    // followee:userId:entityType -> zset(entityId,now)
    public static String getFolloweeKey(int userId,int entityType){
        return PREFIX_FOllOWEE+SPLIT+userId+SPLIT+entityType;
    }


    //某个实体拥有的粉丝
    public static String getFollowerKey(int entityType,int entityId){
        return PREFIX_FOllOWER+SPLIT+entityType+SPLIT+entityId;
    }

    public static String getLoginTicketKey(String ticket){
        return PREFIX_LOGIN_TICKET+SPLIT+ticket;
    }

    public static String getUserKey(int userId){
        return PREFIX_USER+SPLIT+userId;
    }

    public static String getKapthKey(String owner){
        return PREFIX_KAPTH+SPLIT+owner;
    }

    // UV ，单指某一天
    public static  String getUVKey(String date){
        return PREFIX_UV +SPLIT+date;
    }

    // 区间UV 从第几天到第几天
    public static String getUVKey(String startDate, String endDate) {
        return PREFIX_UV + SPLIT + startDate + SPLIT + endDate;
    }

    // 单日活跃用户
    public static String getDAUKey(String date) {
        return PREFIX_DAU + SPLIT + date;
    }

    // 区间活跃用户
    public static String getDAUKey(String startDate, String endDate) {
        return PREFIX_DAU + SPLIT + startDate + SPLIT + endDate;
    }

    // 帖子分数
    public static String getPostScoreKey() {
        return PREFIX_POST + SPLIT + "score";
    }
}
